﻿using Microsoft.Practices.Prism.ViewModel;
using Neudesic.Pulse.Entities;
using System.Collections.ObjectModel;

namespace Neudesic.Pulse.ViewModels.Design
{
    /// <summary>
    /// Design-time view model.  Uses resources to spin up sample instances of models to ease design-time UI/UX development.
    /// </summary>
    public class ActivityListViewModel : NotificationObject
    {

        DesignTimePulseGateway gateway;

        /// <summary>
        /// Gets or sets the activities.
        /// </summary>
        /// <value>The activities.</value>
        public ObservableCollection<ActivityViewModel> Activities { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="ActivityListViewModel" /> class.
        /// </summary>
        public ActivityListViewModel()
        {

            gateway =  new DesignTimePulseGateway();

            // Create a new collection
            Activities = new ObservableCollection<ActivityViewModel>();

            // De-serialize resource file into a new object set.
            PagedActivityList activitySet = gateway.GetActivities();

            // Add the Activities
            if (activitySet != null && activitySet.Activities != null)
            {
                activitySet.Activities.ForEach((a) => Activities.Add(new ActivityViewModel(a, gateway)));
            }
        }
    }
}
